﻿<Window x:Class="BHS.TFSChangsetAnalyser.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:ff="clr-namespace:FunctionalFun.UI"
        xmlns:local="clr-namespace:BHS.TFSChangsetAnalyser.View"
        Title="TFS Changset Analyser"
        MinWidth="450"
        Width="450"
        MinHeight="605"
        MaxHeight="605"
        Height="605"
        Cursor="{Binding Path=IsBusy, Converter={local:BoolToCursorConverter}}"
        >
    <Window.Resources>
        <local:InverseBooleanConverter x:Key="InverseBool" />
    </Window.Resources>
    <StackPanel>
        <GroupBox Header="1. TFS Server Credentials" Margin="10,10,10,10">
            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,5,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="100" />
                    <ColumnDefinition Width="5*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition MinHeight="25"/>
                    <RowDefinition MinHeight="25"/>
                    <RowDefinition MinHeight="25"/>
                    <RowDefinition MinHeight="25"/>
                </Grid.RowDefinitions>

                <CheckBox Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" VerticalAlignment="Center" IsChecked="{ Binding Path=TfsServerConnectionDetails.UseDefaultCredentials }">Use Default Credentials</CheckBox>
                <Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Domain</Label>
                <TextBox Grid.Column="1" Grid.Row="1"
                         Text="{Binding Path=TfsServerConnectionDetails.DomainName, UpdateSourceTrigger=PropertyChanged }" 
                         IsEnabled="{Binding Path=TfsServerConnectionDetails.UseDefaultCredentials, Converter={StaticResource InverseBool}}"/>
                <Label Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right">Username</Label>
                <TextBox Grid.Column="1" Grid.Row="2" 
                         Text="{Binding Path=TfsServerConnectionDetails.Username, UpdateSourceTrigger=PropertyChanged }"
                         IsEnabled="{Binding Path=TfsServerConnectionDetails.UseDefaultCredentials, Converter={StaticResource InverseBool}}"/>
                <Label Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right">Password</Label>
                <PasswordBox Grid.Column="1" Grid.Row="3"
                             ff:PasswordBoxAssistant.BindPassword="true"  
                             ff:PasswordBoxAssistant.BoundPassword="{Binding Path=TfsServerConnectionDetails.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                             IsEnabled="{Binding Path=TfsServerConnectionDetails.UseDefaultCredentials, Converter={StaticResource InverseBool}}"/>
            </Grid>
        </GroupBox>
        <GroupBox Header="2. TFS Server &amp; Project Settings" Margin="10, 10, 10, 10">
            <StackPanel Margin="0,5,0,0">
                <Label>Server</Label>
                <TextBox  Text="{ Binding Path=TfsServerConnectionDetails.TfsServerUrl, UpdateSourceTrigger=PropertyChanged }" />
                <Label>Project Path</Label>
                <TextBox Text="{ Binding Path=TfsServerConnectionDetails.TfsProjectPath, UpdateSourceTrigger=PropertyChanged }" />
            </StackPanel>
        </GroupBox>
        <GroupBox Header="3. Changeset Filter" Margin="10,10,10,10">
            <StackPanel Margin="0,5,0,0">
                <StackPanel Orientation="Horizontal">
                    <Label HorizontalAlignment="Left">Start date:</Label>
                    <DatePicker Margin="5,0,0,0" SelectedDate="{Binding Path=StartDate, UpdateSourceTrigger=PropertyChanged }"/>
                    <Label Margin="30,0,0,0">End date:</Label>
                    <DatePicker Margin="5,0,0,0" SelectedDate="{Binding Path=EndDate, UpdateSourceTrigger=PropertyChanged }" />
                </StackPanel>
                <Grid Margin="0,5,0,0">
                    <Button HorizontalAlignment="Left" Width="100" Command="{ Binding Path=SaveCommand}">Save Settings</Button>
                    <Button HorizontalAlignment="Right" Width="100" Command="{ Binding Path=AnalyseCommand}">Analyse</Button>
                </Grid>
            </StackPanel>
        </GroupBox>
        <GroupBox Header="4. Analysis Results" Margin="10,10,10,10">
            <StackPanel Margin="0,5,0,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="150"/>
                        <ColumnDefinition Width="5*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />

                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right">Nbr Changsets</Label>
                    <Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right">Nbr Changes</Label>
                    <Label Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right">Nbr Reviewed Changes</Label>
                    <Label Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right">% Reviewed Changes</Label>
                    <TextBox Grid.Column="1" Grid.Row="0" Text="{ Binding Path=AnalysisResults.NumberOfChangesets, Mode=OneWay}" />
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{ Binding Path=AnalysisResults.NumberOfChanges, Mode=OneWay}" />
                    <TextBox Grid.Column="1" Grid.Row="2" Text="{ Binding Path=AnalysisResults.NumberOfReviewedChanges, Mode=OneWay}" />
                    <TextBox Grid.Column="1" Grid.Row="3" Text="{ Binding Path=AnalysisResults.PercentageChangesReviewed, Mode=OneWay}" />
                </Grid>
                <Grid Margin="0,5,0,0">
                    <Button Width="100" HorizontalAlignment="Right" Command="{Binding ExportCommand}">Export...</Button>
                </Grid>
            </StackPanel>
        </GroupBox>
    </StackPanel>
</Window>
